{extend name="layout/common_layout" /}
{block name="body"}
<!--tab标签-->
<div class="layui-tab layui-tab-brief">
    <ul class="layui-tab-title">
        <li class=""><a href="{:url('admin/project/index')}">证券列表</a></li>
        <li class="layui-this">证券详情</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <form class="layui-form form-container" action="{:url('admin/project/edit')}" method="post">

                <div class="layui-form-item">
                    <label class="layui-form-label">证券名称：</label>
                    <div class="layui-input-block">
                        <input type="text" name="p_name" value="{$detail.p_name}" placeholder="请输入名称" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">证券头标：</label>
                    <div class="layui-input-block">
                        <button type="button" id="upload-photo-btn" class="layui-btn">上传图集</button>
                        <div id="photo-container">
                            {if condition="!empty($detail['p_photo'])"}
                            <div class="photo-list">
                                <input type="text" name="p_photo[]" style="display: none;"  value="{$detail['p_photo']}" class="layui-input layui-input-inline">
                                <img src="{$detail['p_photo']}" style="width: 100px;"/>
                                <button type="button" class="layui-btn layui-btn-danger remove-photo-btn">移除</button>
                            </div>
                            {/if}
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">收益利率(百分比)：</label>
                    <div class="layui-input-block">
                        <input type="number" name="p_profit" value="{$detail.p_profit}" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">证券每天抢购数量：</label>
                    <div class="layui-input-block">
                        <input type="number" name="p_num" value="{$detail.p_num}" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="p_status" value="1" title="启用" {if condition="$detail.p_status == 1"}checked="checked"{/if}>
                        <input type="radio" name="p_status" value="2" title="禁用" {if condition="$detail.p_status == 2"}checked="checked"{/if}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <input type="hidden" name="p_id" value="{$detail.p_id}">
                        <button class="layui-btn" lay-submit lay-filter="*">保存</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<!--<script src="__JS__/kindeditor/kindeditor.config.js"></script>-->
<!--<script src="__JS__/kindeditor/kindeditor-all-min.js"></script>-->
<script src="__JS__/ueditor/ueditor.config.js"></script>
<script src="__JS__/ueditor/ueditor.all.min.js"></script>
{/block}
{block name="script"}
<script>

    var timestamp = Date.parse(new Date())/1000;
    $(".nowtime").val(timestamp);
    //文件上传
    layui.upload({
        url: "/index.php/api/upload/upload",
        type: 'file',
        elem:'#attar',
        success: function (data) {
            if (data.error === 0) {
                document.getElementById('file').value = data.url;
            } else {
                layer.msg(data.message);
            }
        }
    });

    $(function() {
        var ue = UE.getEditor('content'),
                uploadEditor = UE.getEditor('upload-photo-btn'),
                photoListItem,
                uploadImage;

        uploadEditor.ready(function () {
            uploadEditor.setDisabled();
            uploadEditor.hide();
            uploadEditor.addListener('beforeInsertImage', function (t, arg) {
                $.each(arg, function (index, item) {
                    photoListItem = '<div class="photo-list"><input style="display: none;" type="text" name="photo[]" value="' + item.src + '" class="layui-input layui-input-inline">';
                    photoListItem += '<img src="' + item.src + '" style="width:100px;"/>';
                    photoListItem += '<button type="button" class="layui-btn layui-btn-danger remove-photo-btn">移除</button></div>';

                    $('#photo-container').append(photoListItem).on('click', '.remove-photo-btn', function () {

                        $(this).parent('.photo-list').remove();
                    });

                });
            });
        });

        $('#upload-photo-btn').on('click', function () {
            uploadImage = uploadEditor.getDialog("insertimage");
            uploadImage.open();
        });



        $('.remove-photo-btn').click(function(){

            $(this).parent('.photo-list').remove();
        });
    });
</script>
{/block}